<template>
  <div class="upload-demo">
    <div class="title">慧辨 OCR</div>
    <div class="step-container">
      <el-steps class="steps" :active="activeStep" finish-status="success" simple>
        <el-step title="选择文件" />
        <el-step title="识别结果" />
      </el-steps>
    </div>
    <div class="every" style="display: flex; align-items: center; justify-content: center; height: 45vh">
      <template v-if="activeStep === 0">
        <Document />
      </template>
      <template v-else-if="activeStep === 1">
        <Show />
      </template>
    </div>
    <div v-if="activeStep === 0" class="head">
      <el-button type="primary" round class="start-btn" @click="startOcr" v-loading.fullscreen.lock="fullscreenLoading">
        开始识别
        <el-icon class="el-icon--right">
          <ArrowRight />
        </el-icon>
      </el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ArrowRight } from '@element-plus/icons-vue'
import Document from './Ocr/Document.vue'
import Show from './Ocr/Show.vue'

const activeStep = ref(0)
const fullscreenLoading = ref(false)

const startOcr = () => {
  activeStep.value++
}
</script>

<style scoped>
.title {
  font-size: clamp(40px, 2vw, 60px);
  font-weight: 600;
  margin-bottom: 20px;
}

.step-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 5vh;
}

.steps {
  width: 320px;
}

.upload-demo {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 500px;
  max-width: 900px;
  margin-top: 3vh;
}

.el-icon--upload {
  height: 20vh;
  width: 20vw;
}

.el-upload__text {
  font-size: clamp(15px, 2vw, 25px);
}

.el-upload__tip {
  font-size: clamp(15px, 0.8vw, 25px);
}

.start-btn {
  height: 50px;
  width: 200px;
  margin-top: 5vh;
}

.every {
  display: flex; 
  align-items: center; 
  justify-content: center; 
  height: 45vh;
  background-color: #f3f5fa; 
  border-radius: 8px;        
  width: 100%;              
}

@media (max-width:400px) {
  .upload-demo {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: auto;
    max-width: none;
    margin-top: 10vh;
    width: 100%;
  }

  .step-container {
    margin-bottom: 3vh;
  }

  .steps {
    width: 280px;
  }

  .title {
    font-size: 6vw;
  }

  .every {
    width: 80%;
  }

  .start-btn {
    height: 40px;
    width: 150px;
  }
}
</style>